package com.qf.web;

import com.qf.pojo.Emp;
import com.qf.service.EmpService;
import com.qf.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/findEmpAll")
public class FindEmpAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmpService empService=new EmpServiceImpl();

        List<Emp> list = empService.findEmpALL();
        PrintWriter writer = resp.getWriter();
        writer.println("<html>");
        writer.println("<head><title>商品信息页</title></head>");
        writer.println("<body>");
        writer.println("<table border='1px'>");
        writer.println("<tr>");
        writer.println("<td>id</td>");
        writer.println("<td>ename</td>");
        writer.println("<td>job_id</td>");
        writer.println("<td>mgr</td>");
        writer.println("<td>dept_id</td>");

        writer.println("<td>bonus</td>");
        writer.println("<td>salary</td>");
        writer.println("<td>joindate</td>");
        writer.println("</tr>");
        for(Emp p:list){
            writer.println("<tr>");
            writer.println("<td>"+p.getId()+"</td>");
            writer.println("<td>"+p.getEname()+"</td>");
            writer.println("<td>"+p.getJob_id()+"</td>");
            writer.println("<td>"+p.getMgr()+"</td>");
            writer.println("<td>"+p.getDept_id()+"</td>");
            writer.println("<td>"+p.getBonus()+"</td>");
            writer.println("<td>"+p.getSalary()+"</td>");
            writer.println("<td>"+p.getJoindate()+"</td>");
            writer.println("</tr>");
        }
        writer.println("</table>");
        writer.println("</body>");
        writer.println("<html>");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
